<template>
	<view>
		<!-- #ifndef  H5 -->
		<u-sticky offset-top="0" h5-nav-height="0" bg-color="transparent">
			<u-navbar :is-back="false" title="店长" :title-bold="true" :is-fixed="false" :border-bottom="false"
				:background="{ background: 'rgba(256,256, 256, 1)' }" title-color="#000"></u-navbar>
		</u-sticky>
		<!-- #endif -->
		<view class="list" v-if="lists.length > 0">
			<view class="item" v-for="(item,index) in lists">
				<view class="price">
					{{item.name}}<!-- 价格:{{item.goods_lable_name}} --> 
				</view>
				<view >
					<view class="item_nr" >
						<view class="item_list" v-if="item.user_team[0]">
							<text class="color-fw">{{ item.user_team[0].user_type_text }}昵称：</text><text style="color: #e50003;">{{ item.user_team[0].user.nickname }}</text>
						</view>
						<view class="item_list" v-if="item.user_team[1]">
							<text class="color-fw">{{ item.user_team[1].user_type_text }}昵称：</text><text style="color: #e50003;">{{ item.user_team[1].user.nickname }}</text>
						</view>
						<view class="item_list" v-if="item.user_team[2]">
							<text class="color-fw">{{ item.user_team[2].user_type_text }}昵称：</text><text style="color: #e50003;">{{ item.user_team[2].user.nickname }}</text>
						</view>
						<view v-for="(t,i) in item.user_team.slice(3)" :key="i">
							<view class="dispf " :class=" i != 3 ? 'item_list' : '' ">
								<view>
									<text class="color-fw">顾客{{ kekname[i] }}：</text><text style="color: #00bfbf;">{{ t.user.nickname }}</text>
								</view>
								<view style="display: flex;">
									<text class="color-fw">MM：</text><view style="width: 170rpx;color: blue;">{{ t.parentUser.nickname }}</view>
								</view>
							</view>
						</view>
					</view>
				</view>
			</view>

		</view>
		<view class="none" v-else>
			<view class="empty">
				<u-empty text="暂无成团数据" mode="data"></u-empty>
			</view>
		</view>
		<view class="tabbar">
			<tabbar />
		</view>
	</view>
</template>
<script>
	import {
		apiGetTeamLists
	} from '@/api/team'
	export default {
		data() {
			return {
				lists: [],
				kekname:[
					'一','二','三','四'
				]
			};
		},
		onLoad() {
			// apiGetTeamLists().then(res => {
			// 	let lists = [];
			// 	for (var i = 0; i < res.length; i++) {
			// 		lists[i] = res[i];
			// 		lists[i].dianz = res[i].user_team.filter(item => item.is_team_leader === 1 && item
			// 			.user_type === 1);
			// 		lists[i].diany = res[i].user_team.filter(item => item.is_team_leader === 1 && item
			// 			.user_type === 2);
			// 		lists[i].dians = res[i].user_team.filter(item => item.is_team_leader === 2 && item
			// 			.user_type === 2);
			// 	}
			// 	this.lists = lists
			// })
		},
		onPullDownRefresh(){
			this.listTuan()
		},
		onShow() {
			this.listTuan()
		},
		methods:{
			listTuan(){
				apiGetTeamLists().then(res => {
					let lists = [];
					for (var i = 0; i < res.length; i++) {
						lists[i] = res[i];
						lists[i].dianz = res[i].user_team.filter(item => item.is_team_leader === 1 && item
							.user_type === 1);
						lists[i].diany = res[i].user_team.filter(item => item.is_team_leader === 1 && item
							.user_type === 2);
						lists[i].dians = res[i].user_team.filter(item => item.is_team_leader === 2 && item
							.user_type === 2);
					}
					this.lists = lists
					uni.stopPullDownRefresh()
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.dispf{
		display: flex;
		justify-content: space-between;
		height: 80rpx;
		line-height: 80rpx;
	}
	.list {
		.ident {
			width: 100%;
			font-weight: 300;
		}
		.item {
			width: 700rpx;
			padding: 10rpx;
			margin: 18rpx auto;
			background-image: url('@/static/images/gback.png');
			background-size: cover;
			border-radius: 50rpx;
			background-repeat: no-repeat;
			padding-bottom: 40rpx;
			.color-fw{
				font-weight: 600;
			}
			.item_nr{
				width: 570rpx;
				margin: 0 auto;
				font-size: 32rpx;
				padding-top: 50rpx;
				.item_list{
					height: 80rpx;
					border-bottom: 2rpx solid #fff;
					line-height: 80rpx;
				}
			}

			.price {
				font-size: 40rpx;
				font-weight: bold;
				text-align: right;
				line-height: 60rpx;
				padding-right: 30rpx;
				color: #FFF;
			}
		}
	}

	.none {
		display: flex;
		height: 90vh;
		justify-content: center;
		align-items: center;
		text-align: center;
		font-size: 42rpx;
	}
</style>